package net.dengzixu.java.homework.period16.package1;

import java.util.Random;

/**
 * @author Deng Zixu <admin@dengzixu.com>
 */
public class RightTriangle {
    private final double sSide;
    private final double lSide;
    private static final Random sideRandom = new Random();

    /**
     * 直角三角形
     *
     * @param sSide 边长
     * @param lSide 边长
     */
    public RightTriangle(double sSide, double lSide) {
        this.sSide = sSide;
        this.lSide = lSide;
    }

    /**
     * 直角三角形
     */
    public RightTriangle() {
        this(sideRandom.nextInt(100), sideRandom.nextInt(100));
    }

    /**
     * 计算面积
     *
     * @return 面积
     */
    public double findArea() {
        return (sSide * lSide) / 2;
    }

    /**
     * 计算斜边长
     *
     * @return 斜边长
     */
    public double findHypotenuse() {
        return Math.sqrt(Math.pow(sSide, 2) + Math.pow(lSide, 2));
    }

    /**
     * 打印语句
     *
     * @param sentence 语句
     */
    public static void print(String sentence) {
        System.out.println(sentence);
    }
}
